package org.example.customer.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author jie.luo
 * @description
 * @since 2020-06-18
 */
@FeignClient(
        name = "provider",
        fallback = ProviderClient.ProviderServerFallback.class
)
public interface ProviderClient {

    String CONTEXT_PATH = "/provider";

    @GetMapping(CONTEXT_PATH + "/hello")
    String helloProvider();

    @GetMapping(CONTEXT_PATH + "/user")
    String getUserName(@RequestParam(name = "userId") Integer id);

    class ProviderServerFallback implements ProviderClient {

        @Override
        public String helloProvider() {
            return "服务器出小差啦 , 等等吧 !";
        }

        @Override
        public String getUserName(Integer id) {
            return "服务器出小差啦 , 等等吧 !";
        }
    }

}
